﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class EShop_ManagementBrand : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack) return;
    }
    protected void btnView_Click(object sender, EventArgs e)
    {
        try
        {
            HttpCookie _user = Request.Cookies["userinfo"];
            using (Up1VNDataContext dc = new Up1VNDataContext())
            {
                int day = int.Parse(txtDateView.Text.Substring(0, 2));
                int month = int.Parse(txtDateView.Text.Substring(3, 2));
                int year = int.Parse(txtDateView.Text.Substring(6, 4));
                var query = (from o in dc.brands
                             where o.brand_user == _user["username"].ToString() && o.active == 1
                             && o.date_created.Value.Day == day && o.date_created.Value.Month == month && o.date_created.Value.Year == year
                             select new { o.name, o.category_job, o.phone, o.mobile, o.email, logo=(string)o.logo ?? "" }).ToList();
                if (query.Count() > 0)
                {
                    rptBrand.DataSource = query;
                    rptBrand.DataBind();
                    rptBrand.Visible = true;
                    lblMessage.Visible = false;
                }
                else
                {
                    lblMessage.Visible = true;
                    lblMessage.Text = "Không tìm thấy kết quả tìm kiếm.";
                    rptBrand.Visible = false;
                }
            }
        }
        catch (Exception)
        {
            Response.RedirectToRoute("Error");
        }
    }
   
    
}